﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace ActionSystem.Core.Utils
{
    /// <summary>
    /// 单独加配置文件保存要初始化的类型
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class PoolInitAttribute : Attribute
    {
        public const string INIT_METHOD_NAME = "PreInitPool";
        public Type type;
        public int capacity;
        public PoolInitAttribute(Type poolType,int capacity = 10)
        {
            this.type = poolType;
            this.capacity = capacity;
        }
        //初始化Pool
        public static void InitPools(PoolInitAttribute initAttribute)
        {
            if(initAttribute!=null)
                initAttribute.type.InvokeMember(INIT_METHOD_NAME, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[]{initAttribute.capacity});
        }
    }
}

